/*
 * Filename    : State_Logo.java
 * Projectname : Sound Of Indonesia
 * Date        : Nov 1, 2012 , 1:09:52 PM 
 * 
 * PratamaNurWijaya
 */

package id.pratama.soundofindonesia.state;

import id.pratama.soundofindonesia.Utils;

import org.andengine.entity.scene.Scene;
import org.andengine.entity.scene.background.Background;
import org.andengine.util.color.Color;

public class State_Logo extends State_Play
{
	private boolean	isLoading	= false;

	@Override
	protected void onCreateResources()
	{
		super.onCreateResources();
		grafik.loadLogo();

	}

	@Override
	protected Scene onCreateScene()
	{
		m_Scene.setBackground(new Background(Color.WHITE));
		grafik.attachLogo();
		switchState(STATE_LOGO);

		return super.onCreateScene();
	}

	@Override
	public void onUpdate(float pSecondsElapsed)
	{

		if (State_Menu_Current == STATE_LOGO)
		{
			if (grafik.spr_Logo.hasParent() && !isLoading)
			{
				isLoading = true;

				teks.loadFontSmall();
				teks.loadFontMedium();
				teks.loadFontBig();

				grafik.loadMenuDaerah();

				grafik.loadMenuMainBg();

			}

			if (grafik.tex_Menu_Bg.isLoadedToHardware())
			{
				grafik.detachLogo();

				switchState(STATE_MENU_MAIN);
				return;
			}
		}

		super.onUpdate(pSecondsElapsed);
	}

	@Override
	protected void switchState(byte state)
	{
		super.switchState(state);

		State_Menu_Current = state;

		switch (State_Menu_Current)
		{
			case STATE_MENU_MAIN:
				createMenuMain();
				break;

			case STATE_MENU_DAERAH:
				createMenuDaerah();
				break;

			case STATE_MENU_ALAT_MUSIK:
				break;

			case STATE_DESKRIPSI:
				break;

		}
	}
}
